const Service = require('egg').Service;

class HomeService extends Service {
  async type() {
    // const sql = 'SELECT * FROM banner';
    const banner = await this.app.mysql.select('web-type');
    return banner;
  }

  async add(params) {
    const res = await this.app.mysql.insert('website', params);
    return res;
  }

  async list({
    page = 1,
    page_size = 100,
    ...where
  }) {
    const res = await this.app.mysql.select('website', {
      where,
      limit: page_size,
      offset: (page - 1) * page_size,
    });
    return res;
  }
}

module.exports = HomeService;
